<%@ page language="java" import="java.util.*" isELIgnored="false" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 搜索</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    
    <link href="static/css/bootstrap.min.css" rel="stylesheet">
    <link href="static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="static/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="static/css/page.css" rel="stylesheet" type="text/css" />
    
	<script type="text/javascript" src="static/js/jquery-2.2.2.js"></script>
	<script type="text/javascript" src="static/js/page.js"></script>
	<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="static/layer/layer.js"></script>
    <style type="text/css">
    .delete_css{
    	position:absolute;
    	top:0px;
    	right:10px;
    }
    
    a:link{
    	color:rgb(51,122,183);    <!--未点击的超链接显示黑色--->
	}
	a:hover{
    	color:purple; <!----当鼠标指向超链接时变成紫色----->
	}
	a:visited{
    	color:red;  <!----当超链接被访问过后变成红色----->
	}
    
    
    </style>
    
    <script type="text/javascript">
    
  //扩展jQuery发送非ajax的post请求：使用jQuery 在内存中建立一个form对象，然后调用这个对象的submit方法
	$.extend({
	    StandardPost:function(url,args){
	        var form = $("<form method='post'></form>"),input;
	        form.attr({"action":url});
	        $.each(args,function(key,value){
	            input = $("<input type='hidden'>");
	            input.attr({"name":key});
	            input.val(value);
	            form.append(input);
	        });
	        form.submit();
	    }
	});
    
    	function openApprEdit(id){
    		//弹出一个iframe层
             layer.open({
             type: 2,
             title: '新闻审核',
             maxmin: true,
             shadeClose: true, //点击遮罩关闭层
             area : ['800px' , '520px'],
             content: 'newsint/openApprEdit?id='+id,
             success: function(layero, index){
                 var body = layer.getChildFrame('body',index);//建立父子联系
                 // console.log(arr); //得到iframe页的body内容
                 // console.log(body.find('input'));
                 body.find('#appr_page_num').val(${newsInts.pageNo});
             },
             end: function () {
                 location.reload();
             }
            });
    	}
    	
    	function deleteNews(id){
    		layer.open({
    			  type: 1,
    			  shift:-1,//动画风格,默认1 默认情况下有的浏览器点击取消、确定按钮为什么必须点击两下才能触发点击事件，css3动画的延迟问题，可使用shift:-1
    			  area: ['450px', '250px'],
    			  shadeClose: true, //点击遮罩关闭
    			  content: '\<\div style="padding:20px;text-align:center;color:red;font-family:微软雅黑;">确定删除？\<\/div>\<textarea id="delete_appr_reason" class="form-control" placeholder="请输入内容（不超过200个字）" maxlength="200" rows="4">\<\/textarea>',
    			  btn: ['确定', '取消'],
    			  yes: function(index,layero){
    	              var deleteApprReason = layero.find('#delete_appr_reason').val();
    	              layer.close(index);
    		    	  layer.load(2);
    		    	  //此处演示关闭
    		    	  setTimeout(function(){
    		    	    layer.closeAll('loading');
    		    	  }, 2000);
    		    	  $.StandardPost('newsint/apprDelete',{'id':id,'reason':deleteApprReason,'page':'${newsInts.pageNo}'});
    			  }
    			});
    		
    	}
    	
    	function likeSearch(inputName){
    		$('#search_param').attr("name",inputName);
    	}
    </script>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="search-form">
                        <form action="newsint/getLikeApprNewsInts" method="post">
                            <div class="input-group">
                                <input type="text" id="search_param" placeholder="输入关键词" name="title" value="${likeParam}" class="form-control input-lg"/>
                                <div class="input-group-btn">
                                    <button class="btn btn-lg btn-primary" onclick="likeSearch('title')" type="submit">搜索标题</button>
                                </div>&nbsp;
                                <div class="input-group-btn">
                                    <button class="btn btn-lg btn-primary" onclick="likeSearch('introduce')" type="submit">搜索摘要</button>
                                </div>&nbsp;
                                <div class="input-group-btn">
                                    <button class="btn btn-lg btn-primary" onclick="likeSearch('URL')" type="submit">搜索URL</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="hr-line-dashed"></div>
                    
                    <c:forEach items="${newsInts.datas}" var="newsint" varStatus="statu">
                    <div style="position: relative;" class="search-result">
                        <h3>
                            <a href="${newsint.URL}" target="_blank" >${newsint.title}</a>
                        </h3>
                        <div style="width:70%; overflow: hidden;text-overflow:ellipsis;white-space: nowrap;">
                          	 ${newsint.introduce}</div>
                         <div class="delete_css" >
                         	<button type="button" class="btn btn-primary" onclick="openApprEdit('${newsint.id}')">审核</button>
                         	<button type="button" class="btn btn-danger" onclick="deleteNews('${newsint.id}')" >删除</button>
                         </div>
                         <div class="hr-line-dashed"></div>
                    </div>
                    </c:forEach>
                    
                   
                    <div class="text-center">
                    
                    	<div class="message">共<i class="blue">${newsInts.total}</i>条记录，每页显示&nbsp;<i class="blue"><label>${newsInts.onePageNum}</label>&nbsp;</i>条</div>
						<!--pagelistcount 设置一页显示多少条数据  -->
						<ul class="page" style="margin-left: 0px; margin-top:8px; padding-left: 0px;" maxshowpageitem="5" pagelistcount="${newsInts.onePageNum}" id="page"></ul>
						<br>
                    <!-- 
                        <div class="btn-group">
                            <button class="btn btn-white" type="button"><i class="fa fa-chevron-left"></i>
                            </button>
                            <button class="btn btn-white">1</button>
                            <button class="btn btn-white  active">2</button>
                            <button class="btn btn-white">3</button>
                            <button class="btn btn-white">4</button>
                            <button class="btn btn-white">5</button>
                            <button class="btn btn-white">6</button>
                            <button class="btn btn-white">7</button>
                            <button class="btn btn-white" type="button"><i class="fa fa-chevron-right"></i>
                            </button>
                        </div>
                         -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
	var nowtime = new Date().getTime();
	$('a').each(function(){
		var url = $(this).attr("href");
		if(url.indexOf("?")>0){//判断连接是否已存在参数
			$(this).attr("href",url+"&nowtime="+nowtime);
		}else{
			$(this).attr("href",url+"?nowtime="+nowtime);
		}
	 });
	
    var isfirst = true;
	var GG = {
		"kk" : function(mm) {
			if(!isfirst){
				var likeParam = '${likeParam}';
				var url = "newsint/newsInt_aprpage?size=${newsInts.onePageNum}&page="+mm;
				
				if(likeParam!=''){
					$.StandardPost('newsint/getLikeApprNewsInts',{'page':mm,'${likeParamName}':'${likeParam}'});
				}else{
					window.location.href = url;
				}
				
			}else{
				isfirst = false;
			}
			
		}
	};
	$("#page").initPage(${newsInts.total}, ${newsInts.pageNo}, GG.kk);
</script>
</body>
</html>
